#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int p[N], sz[N];
int n, m;	
int u[N], v[N];
LL ans[N];
int find(int x)
{
	if (x != p[x])p[x] = find(p[x]);
	return p[x];
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> u[i] >> v[i];	
	}
	for (int i = 1; i <= n; i++) {
		p[i] = i;
		sz[i] = 1;
	}
	ans[m] = (LL)n * (n - 1) / 2;
	for (int i = m; i > 1; i--) {
		int a = find(u[i]), b = find(v[i]);
		if (a == b)ans[i - 1] = ans[i];
		else {
			ans[i - 1] = ans[i] - (LL)sz[a] * sz[b];
			p[a] = b;
			sz[b] += sz[a];
		}
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}